home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Developer Helper 1: Phil & Dave's Excellent CD
/
Excellent CD HFS.raw
/
Moof
/
Goodies
/
MPW Goodies
/
MPW Goodies⁄DTS
/
AddChange
< prev
next >
Wrap
Text File
|
2022-08-05
|
4KB
|
148 lines
# AddChange - add changes to a window
#
# Usage: AddChange window [commentFile]
#
# Status: AddChange may return the following status values:
#
# 0 the change was added
# 1 error
# 4 the user canceled
#
# AddChange adds a change from the file, commentFile, to the window.
# The change is inserted at the LastChange marker. If no marker is
# present, a dialog is presented, allowing the user to add a blank header
# to the file. If no commentFile is passed, the comment field is left blank.
Set CaseSensitive 0
Set Exit 0
Begin
Set Window "{1}" # add change to this file (must be open window)
Set Comment "{2}" # get comment from this file (should not be open)
# get short name of window
If "{Window}" =~ /:*([¬:]+:*)*([¬:]+.([a-z]+)®2)®1/
Set Short "{®1}"
Set Suffix {®2}
Else If "{Window}" =~ /:*([¬:]+:*)*([¬:]+)®1/
Set Short "{®1}"
Set Suffix ""
Else
Exit 1
End
If "{Suffix}" =~ /[chri]/ # comments for C and Rez
Set StartComment "/*"
Set EndComment "*/"
Set Leader ""
Else If "{Suffix}" == "cp" # comments for C++
Set StartComment "/*"
Set EndComment "*/"
Set Leader ""
Else If "{Suffix}" == "p" # comments for Pascal
Set StartComment "∂{"
Set EndComment "∂}"
Set Leader ""
Else If "{Suffix}" == "a" # comments for assembly language
Set StartComment ";"
Set EndComment ";"
Set Leader ";"
Else # comments for shell scripts, Makefiles etc.
Set StartComment "#"
Set EndComment "#"
Set Leader "#"
End
# find change history
Find LastChange "{Window}" # find the change history
If {Status} != 0 # create one if necessary
Find • "{Window}" # go to the top of the window
Mark /•∂tChange History:[ ∂t]*∂n[ ∂t]*∂n/Δ LastChange "{Window}"
If {Status} != 0
If "{Comment}" != ""
Confirm -t "There is no “LastChange” marker in “{Short}”. Do you want to add a header?"
Set ConfirmStatus {Status}
If {ConfirmStatus} == 5 # cancel: report this to the caller
Exit 4
Else If {ConfirmStatus} == 4 # no: don't add the change
Exit 0
End # yes: go on with life as usual
End
If "{Contents}" == ""
Set Contents "*** put contents here ***"
End
If "{Writers}" == ""
Set Writers "*** put writers here ***"
End
If "{Copyright}" == ""
If "`Date -d`" =~ /[a-z]+, [a-z]+ [0-9]+, ([0-9]+)®1/
Set Copyright "© {®1} by Apple Computer, Inc., all rights reserved."
Else
Set Copyright "*** put copyright here ***"
End
End
Begin
Echo "{StartComment}"
Echo "{Leader}∂tFile:∂t∂t{Short}"
Echo "{Leader}"
Echo "{Leader}∂tContains:∂t{Contents}"
Echo "{Leader}"
Echo "{Leader}∂tWritten by:∂t{Writers}"
Echo "{Leader}"
Echo "{Leader}∂tCopyright:∂t{Copyright}"
Echo "{Leader}"
Echo "{Leader}∂tChange History:"
Echo "{Leader}"
Echo "{Leader}"
Echo "{Leader}∂tTo Do:"
Echo "{EndComment}"
Echo
End > "{Window}.§"
Find !0 "{Window}"
Find Δ¡3 "{Window}"
Mark -y § LastChange "{Window}"
End
End
# concoct the change line for the change history
If "`Date -d -s` " =~ /(?«7,8»)®1≈/
Set ChangeDate "{®1}"
Else
Set ChangeDate "??/??/??"
End
If "{UserInitials}" == "" # no initials, use user name instead
Set UserInitials "" # in case it was not defined before
Set TrimmingName "{User}" # use this for the loop
Loop
If "{TrimmingName}" =~ /([a-z])®1[a-z.]* (?*)®2/
Set UserInitials {UserInitials}{®1}
Set TrimmingName "{®2}"
Else If "{TrimmingName}" =~ /([a-z])®1[a-z.]*/
Set UserInitials {UserInitials}{®1}
Break
Else
Set UserInitials "{User}∂n∂t∂t∂t∂t∂t"
Break
End
End
End
# put the comment at the top of the change history
Find Δ§ "{Window}" # put the comment into the change history
Echo -n "{Leader}∂t∂t{ChangeDate}∂t{UserInitials}∂t∂t" >> "{Window}.§"
Catenate "{Comment}" >> "{Window}.§"
If {Status} != 0
Echo -n "*** put comment here ***" >> "{Window}.§"
End
Echo >> "{Window}.§"
# mark the change history again
Mark -y § LastChange "{Window}"
End ∑Dev:Null